<template>
    <div class="hotartist">
        <!-- 标题 -->
        <div class="title tanxin">
            <div class="title_l tanxin">
                <i class="quan"></i>
                <h2>{{ name }}</h2>
            </div>
            <div class="title_r">
                <span @click="$router.push('/discover/artist/hot')">更多</span>
                <i class="jiantou"></i>
            </div>
        </div>
        <!-- 列表 -->
        <div class="artist_list">
            <ul class="select tanxin">
                <li v-for="(item, index) in letter" :key="index" :class="{'active':item.initial == -1 || item.initial == $route.query.initial}" @click="Go(item)">{{ item.name }}</li>
            </ul>
            <ul class="artist tanxin">
                <li v-for="(item, index) in ArtistList" :key="index" @click="$router.push(`/artlist/${item.id}`)">
                    <div class="header">
                        <img :src="item.picUrl" alt="" style="width:130px; height:130px;">
                        <i :title="item.name+'的音乐'" class="mask"></i>
                    </div>
                    <div class="info tanxin">
                        <span class="ellipsis" :title="item.name+'的音乐'">{{ item.name }}</span>
                        <i :title="item.name+'的个人主页'" class="people" v-show="item.accountId"></i>
                    </div>
                </li>
            </ul>
        </div>
         <!-- 榜单 -->
         <div class="artistbang_list">
            <ul class="tanxin">
                <li v-for="(item, index) in ArtistBang" :key="index" @click="$router.push(`/artlist/${item.id}`)">
                    <span class="ellipsis" :title="item.name+'的音乐'">{{ item.name }}</span>
                    <i :title="item.name+'的个人主页'" class="people" v-show="item.accountId"></i>
                </li>
            </ul>
        </div>
    </div>
</template>

<script>
import { ArtistListApi } from "@/request/api";
export default {
    data () {
        return {
            ArtistList: "",
            ArtistBang: "",
            letter: [
                {name:"热门",initial:-1},
                {name:"A",initial:65},
                {name:"B",initial:66},
                {name:"C",initial:67},
                {name:"D",initial:68},
                {name:"E",initial:69},
                {name:"F",initial:70},
                {name:"G",initial:71},
                {name:"H",initial:72},
                {name:"I",initial:73},
                {name:"J",initial:74},
                {name:"K",initial:75},
                {name:"L",initial:76},
                {name:"M",initial:77},
                {name:"N",initial:78},
                {name:"O",initial:79},
                {name:"P",initial:80},
                {name:"Q",initial:81},
                {name:"R",initial:82},
                {name:"S",initial:83},
                {name:"T",initial:84},
                {name:"U",initial:85},
                {name:"V",initial:86},
                {name:"W",initial:87},
                {name:"X",initial:88},
                {name:"Y",initial:89},
                {name:"Z",initial:90},
                {name:"其他",initial:0},
            ]
        }
    },
    computed: {
        name() {
            if(this.$route.query.name == undefined) return "华语男歌手";
            return this.$route.query.name;
        },
        area() {
            if(this.$route.query.area == undefined) return 7;
            return this.$route.query.area;
        },
        type() {
            if(this.$route.query.type == undefined) return 1;
            return this.$route.query.type;
        },
        initial() {
            if(this.$route.query.initial == undefined) return -1;
            return this.$route.query.initial
        } 
    },
    created() {
        // 获取华语歌手
        ArtistListApi({
            type: this.type,
            area: this.area,
            initial: this.initial
        }).then((res) => {
            // console.log(res);
            // console.log(this.$route.query.area);
            // console.log(this.$route.query.type);
            this.ArtistList = res.data.artists.slice(0, 10);
            this.ArtistBang = res.data.artists.slice(10);
        })
    },
    methods: {
        Go(item) {
            this.$router.push({
                path: "/discover/artist/list",
                query: {
                    name: this.name,
                    area: this.area,
                    type: this.type,
                    initial: item.initial,
                },
            });
            this.$router.go(0);
        },
    }
}
</script>
 
<style lang = "less" scoped>
@import "../../assets/base.less";
.hotartist {
    .title {
        height: 40px;
        border-bottom: 2px solid @red;
        display: flex;
        align-items: center;
        .title_l {
            .quan {
                float: left;
                width: 15px;
                height: 15px;
                margin: 5px 10px;
                background: url('../../assets/images/public/index.png') no-repeat -235px -164px;
            }
            h2 {
                font-size: 24px;
                color: #333;
                cursor: pointer;
                &:hover {
                    cursor: pointer;
                    text-decoration: underline;
                }
            }
        }
        .title_r {
            span {
                font-size: 12px;
                color: #333;
                cursor: pointer;
                &:hover {
                    cursor: pointer;
                    text-decoration: underline;
                }
            }
            .jiantou {
                float: right;
                width: 12px;
                height: 12px;
                margin: 5px;
                background: url('../../assets/images/public/index.png') no-repeat 0 -242px;
            }
        }
    }
    .artist_list {
        .select {
            display: flex;
            justify-content: space-between !important;
            margin-top: 20px;
            li {
                width: 21px;
                height: 24px;
                line-height: 24px;
                text-align: center;
                font-size: 14px;
                color: #333;
                &:hover {
                    cursor: pointer;
                    text-decoration: underline;
                }
                &:first-of-type {
                    width: 45px;
                }
                &:last-of-type {
                    width: 45px;
                }
            }
            .active {
                background: #c20c0c;
                border-radius: 2px;
                color: #fff;
            }
        }
        .artist {
            flex-wrap: wrap;
            display: flex;
            justify-content: space-between !important;
            padding-bottom: 30px;
            li {
                width: 130px;
                height: 150px;
                margin-top: 20px;
                &:nth-of-type(5n) {
                    margin-right: 0;
                }
                .header {
                    position: relative;
                    height: 130px;
                    width: 130px;
                    overflow: hidden;
                    .mask {
                        cursor: pointer;
                        position: absolute;
                        top: 0;
                        left: 0;
                        height: 130px;
                        width: 130px;
                        background: url("../../assets/images/public/coverall.png") no-repeat -10px 0px;
                    }
                    &:hover {
                        img {
                            transform: scale(1.2);
                        }
                    }
                }
                .info {
                    padding-top: 5px;
                    font-size: 12px;
                    display: flex;
                    align-items: center;
                    span {
                        &:hover {
                            cursor: pointer;
                            text-decoration: underline;
                        }
                    }
                    .people {
                        cursor: pointer;
                        width: 18px;
                        height: 18px;
                        display: block;
                        background: url("../../assets/images/public/icon.png") no-repeat 0px -739px;
                    }
                }
            }
        }
    }
    .artistbang_list {
        ul {
            flex-wrap: wrap;
            display: flex;
            justify-content: space-between !important;
            border-top: 1px dotted #333;
            padding-top: 10px;
            li {
                width: 130px;
                height: 30px;
                font-size: 12px;
                display: flex;
                align-items: center;
                &:nth-of-type(5n) {
                    margin-right: 0;
                }
                span {
                    &:hover {
                        cursor: pointer;
                        text-decoration: underline;
                    }
                }
                .people {
                    cursor: pointer;
                    width: 18px;
                    height: 18px;
                    display: block;
                    margin:0 0 0 4px;
                    background: url("../../assets/images/public/icon.png") no-repeat 0px -739px;
                }
            }
        }
    }
}
</style>